/*
Code for figure A1
*/


global dumOutcomes dAny   dPsy dPhy // dCont dArgs dPsyPhy

use "$data_folder/endes_with_enaho_occup", clear


global coefs
foreach year of numlist 2012/2019 {
	global coefs $coefs `year'.year#c.pct_chng_wgt
}

*regs with ENDES

fvset base 2019 year



foreach out in controll sexual psyco  our_physi our_any {
	
	eststo a`out'lin: reghdfe any_`out'_last_12 year##c.pct_chng_wgt, a(sector1r4) cluster(sector1r4)

	
}



// Regs with our data /spec 

use "$data_folder/NBER_HPI_PANEL_with_bartick.dta", clear


label define yearLab 2021 "July-Aug 2020"   2020 "April-May 2020" 

label values year yearLab 
foreach out in $dumOutcomes {

	fvset base 2019 year
	eststo prePlotSec`out' :   reghdfe `out'  year##c.pct_chng_wgt_v2, a(id_cases) cluster(ubigeo) 

	
	
}



global yscale ylabel(-0.001(0.0005)0.001)




// dAny dArgs dCont dPsy dPhy dPsyPhy
global plotRegionMargin plotregion(margin(l=0 t=0 b=0 r=6 ))
global plotSettings 		keep(*year#c.pct_chng_wgt *year#c.pct_chng_wgt_v2) yline(0) vertical ///
		graphregion(color(white) )  scheme(s2mono)  ///		
		ylabel(-0.003(0.0015)0.003 , labsize(small) angle(0)) xlabel(,angle(-45) labsize(small) ) ///
		omitted baselevels  ///
		legend(order( 2 "Pre-Pandemic, ENDES Survey" 4 "Pandemic, Our Survey"))



coefplot ( apsycolin, rename(([0-9]*).year#c.pct_chng_wgt = \1, regex) omitted baselevels ) ///
		(prePlotSecdPsy , rename((.*)#c.pct_chng_wgt_v2 = \1, regex) omitted baselevels ) ///
		, ///
		$plotSettings ///
		$plotRegionMargin   ///
		title("Psychological", size(medium)) ///
		name(psych, replace) ///



coefplot ( aour_physilin, rename(([0-9]*).year#c.pct_chng_wgt = \1, regex) omitted baselevels ) ///
		(prePlotSecdPhy , rename((.*)#c.pct_chng_wgt_v2 = \1, regex) ) ///
		, ///
		$plotSettings ///
		$plotRegionMargin   ///
		title("Physical", size(medium)) ///
		name(phys, replace)

		
coefplot ( aour_anylin, rename(([0-9]*).year#c.pct_chng_wgt = \1, regex) omitted baselevels ) ///
		( prePlotSecdAny , rename((.*)#c.pct_chng_wgt_v2 = \1, regex) ) ///
		, ///
		 $plotSettings ///
		 $plotRegionMargin   ///
		title("Any", size(medium)) ///
		name(any, replace) 
		


***COMBINING GRAPHS
grc1leg  psych phys any, ///
			   cols(2)  ycommon ///
			   graphregion(color(white)) ///
			   title("Coefficient on Employment Shock", size(large))  ///
			  
graph export "$tex_folder/all_pretrend_stacked_ipv_coefs_sectors_lin.png", as(png) replace
 

